package com.ysh.dao.store;

import com.ysh.domain.store.Company;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CompanyMapper {
    //添加
    @Insert("insert into st_company values (#{id},#{name},#{expirationDate},"+
            "#{address},#{licenseId},#{representative},"+
            "#{phone},#{companySize},#{industry},"+
            "#{remarks},#{state},"+
            "#{city})")
    int save(Company company);

    //删除
    // @Delete("delete from st_company where id =#{id}")

    int deleteByIds(String[] ids);

    //更新
    @Update("update st_company set name = #{name}," +
            "        expiration_date = #{expirationDate}," +
            "        address = #{address}," +
            "        license_id = #{licenseId}," +
            "        representative = #{representative}," +
            "        phone = #{phone}," +
            "        company_size = #{companySize}," +
            "        industry = #{industry}," +
            "        remarks = #{remarks}," +
            "        state = #{state}," +
            "        city = #{city}" +
            "        where id = #{id} ")
    int update(Company company);

    //根据id查询
    @Select("select * from st_company where id = #{id}")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "expiration_date",property = "expirationDate"),
            @Result(column = "address",property = "address"),
            @Result(column = "license_id",property = "licenseId"),
            @Result(column = "representative",property = "representative"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "company_size",property = "companySize"),
            @Result(column = "industry",property = "industry"),
            @Result(column = "remarks",property = "remarks"),
            @Result(column = "state",property = "state"),
            @Result(column = "city",property = "city"),
    })
    Company findById(String id);

    //查询所有
    @Select("select * from st_company")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "expiration_date",property = "expirationDate"),
            @Result(column = "address",property = "address"),
            @Result(column = "license_id",property = "licenseId"),
            @Result(column = "representative",property = "representative"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "company_size",property = "companySize"),
            @Result(column = "industry",property = "industry"),
            @Result(column = "remarks",property = "remarks"),
            @Result(column = "state",property = "state"),
            @Result(column = "city",property = "city"),
    })
    List<Company> findAll();

}
